﻿        function GetProjectGrades()
        {
               var projectID = $("#projectID").val();
               if (projectID != "")
                   $('#GradeDetails').load('@Url.Content("~/Home")/GetProjectGrades?projectID=' + projectID);
               else
                   $('#GradeDetails').html("");
        };

        $(function () {
            GetProjectGrades();
       });

       $(function () {
            $("#btnShowProposalGrading").click(function (e) {
                e.preventDefault();
                var projectID = $("#projectID").val();
                if (projectID == "")
                    jAlert("Please select a Project first.", "Project Grading");
                else
                    GetProjectGrades();
            })
        });

       $(function () {
           $("#btnEditGrading").click(function () {
               var projectID = $("#projectID").val();
               if (projectID == "")
                   jAlert("Please select a Project first.", "Project Grading");
               else
                   $("#TheForm").submit();
           })
       });



       /*

                  @if (item.PeriodId != null && ViewBag.StudentID == null && Qu.SeniorProject.Model.ProjectRepository.IsInterimExaminationOpen(item.PeriodId, item.ProjectID))
           {

                 @Html.ActionLink("Project Grading", "Grading", "Grading", new { projectID = item.ProjectID, gradingType = "Proposal" }, null)
                 <br /><br />
           }
           else
               if (item.PeriodId != null && ViewBag.StudentID == null && Qu.SeniorProject.Model.ProjectRepository.IsProjectExaminationOpen(item.PeriodId, item.ProjectID))
               {

                    @Html.ActionLink("Project Grading", "Grading", "Grading", new { projectID = item.ProjectID, gradingType = "Final" }, null)
                    <br /><br />
               }
         
            
@*            @if (item.IsOpen && ViewBag.StudentID == null)
            {
                    <br />
                    @Ajax.ActionLink("View Project Grade", "GetProjectGrades", new { projectID = item.ProjectID, gradingType = "Final" },
                    new AjaxOptions { UpdateTargetId = "GradeDetails", HttpMethod = "GET" })
            }*@
                    
            @if (item.Role != "Examiner" && item.Role != "SecondExaminer")
            {
                @Html.ActionLink("Edit Project Details", "EditProject", new { id = item.ProjectID })
            
@*                if (item.IsOpen && ViewBag.StudentID == null)
                {
                     <br /><br />
                       @Html.ActionLink("View Project Grade", "ProjectGrades", new { projectID = item.ProjectID, gradingType = "Final" })

                     
                      if (!item.IsComplete)
                      {
                          <br /><br />
                              <div id="MarkProjectAsCompleteDiv">
                              @Ajax.ActionLink("Release Grades to Students", "MarkProjectAsComplete", new { projectID = item.ProjectID },
                                         new AjaxOptions
                                         {
                                             UpdateTargetId = "message_bar",
                                             HttpMethod = "POST",
                                             Confirm = "Are you sure you would like to release the grades to students? Please make sure that all the expected deliverables was submitted to you (note that often once the students access their grades then 'disappear').",
                                             OnSuccess = "deleteConfirmation"
                                         })
                             </div>
                      }

                }*@
                
                 @* Not used*@
                 @*  @Ajax.ActionLink("View Proposal Grading", "GetProjectGrades", new { projectID = item.ProjectID, gradingType = "Final" },
                            new AjaxOptions { UpdateTargetId = "GradeDetails", HttpMethod = "GET" })*@
            }
            
            @*ToDo only show within date range*@
            @if (item.IsOpen && ViewBag.StudentID != null && item.IsComplete)
            {
                <br /><br />
                 @Html.ActionLink("View Project Grade", "GetStudentGrades", new { projectID = item.ProjectID, studentID = ViewBag.StudentID, gradingType = "Final", showSummaryOnly = true })

@*                 <br />
                 @Html.ActionLink("View Project Grade", "GetStudentGrades", new { projectID = item.ProjectID, studentID = ViewBag.StudentID, gradingType = "Final" })*@
            }

       */